package com.test.kotlin05

import java.io.File

open class Product(val name:String) {//open关键字，才能作为基类

    fun description() = "Product:$name"
    open fun load() = "Nothing~"//open关键字，才能让子类复写该方法
}

class LuxuruyProduct:Product("Luxury"){
    override fun load() = "Luxury Nothing~ "

    fun  special() = "Luxury special function "
}

fun main() {
    val p:Product = LuxuruyProduct()
    println(p.load())

    println(p is Product)
    println(p is LuxuruyProduct)
    println(p is File)

    if(p is LuxuruyProduct){
        println( (p as LuxuruyProduct).special())//类型转换

        p.special()//转换后，可以直接调用 子类反复
    }


    println(p is Any) //Any是所有类的超类

}